package com.奇技淫巧;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class 迭代器 {


    public static void main(String[] args) {
        List<Object> list = new ArrayList<>();
        list.add(new StringBuffer("AA"));
        list.add(new StringBuffer("BB"));
        list.add(new StringBuffer("CC"));
        Iterator<Object> iterator = list.iterator();
        while (iterator.hasNext()){
            Object ss = iterator.next();
            ss=new StringBuffer("DD");
            System.out.println(ss);

        }
        Iterator<Object> iterator2 = list.iterator();
        while (iterator2.hasNext()){
            System.out.println(iterator2.next());

        }
    }
}
